package com.nbsaas.boot.entity.customer;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.code.annotation.bean.StoreStateBean;
import com.nbsaas.boot.code.annotation.data.Dict;
import com.nbsaas.boot.code.annotation.data.DictItem;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import com.nbsaas.boot.rest.enums.StoreState;
import com.nbsaas.boot.rest.filter.Operator;
import com.nbsaas.boot.user.data.entity.UserInfo;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

@StoreStateBean
@Comment( "会员资料表")
@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "会员资料", model = "会员", menu = "1,60,61", searchWidth = "100", viewWidth = "120")
@Entity
@Table(name = "bs_member_profile")
public class MemberProfile extends AbstractEntity {

    @Comment("个人照片")
    @FormField(title = "个人照片",  grid = true,type = InputType.image)
    private String photo; // BLOB 类型的数据，通常为字节数组

    @Comment("会员姓名")
    @SearchItem(name = "name", key = "name", label = "姓名")
    @FormField(title = "姓名",  grid = true, required = true)
    @Column(length = 50)
    private String name;

    @Comment("出生年月")
    @FormField(title = "出生年月", type = InputType.date, width = "160", grid = true)
    private Integer birthYear;


    @Comment("性别")
    @FormField(title = "性别", grid = true,type = InputType.dictionary)
    @SearchItem(name = "gender", key = "gender", label = "性别",operator = Operator.eq)
    @Column(length = 10)
    private String gender;


    @Comment("电话")
    @Column(length = 30)
    private String phone;

    @Comment("身高")
    @FormField(title = "身高", grid = true)
    private Integer height;

    @Comment("体重")
    @FormField(title = "体重", grid = true)
    private Integer weight;

    @Comment("学历")
    @FormField(title = "学历",  grid = true)
    @Column(length = 20)
    private String education;

    @Comment("职业")
    @FormField(title = "职业", grid = true)
    @Column(length = 50)
    private String job;

    @Comment("工作地")
    @FormField(title = "工作地", grid = true)
    @Column(length = 50)
    private String workLocation;

    @Comment("收入")
    @FormField(title = "收入", grid = true, type = InputType.el_input_number, sort = true)
    private Double income;

    @Comment("家庭状况")
    @FormField(title = "家庭状况", grid = true)
    @Column(length = 200)
    private String familyStatus;

    @Comment("婚姻状态")
    @SearchItem(name = "maritalStatus", key = "maritalStatus", label = "婚姻状态",operator = Operator.eq,type = InputType.dictionary)
    @FormField(title = "婚姻状态",  grid = true,type = InputType.dictionary)
    @Column(length = 20)
    private String maritalStatus;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "有"),
                    @DictItem(value = 0, label = "无")
            }
    )
    @Comment("是否带孩")
    @SearchItem(name = "hasChildren", key = "hasChildren", label = "是否带孩",operator = Operator.eq,type = InputType.dictionary,classType = Integer.class)
    @FormField(title = "是否带孩",  grid = true,type = InputType.dictionary)
    private Integer hasChildren;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "有"),
                    @DictItem(value = 0, label = "无")
            }
    )
    @Comment("是否有车")
    @SearchItem(name = "hasCar", key = "hasCar", label = "是否有车",operator = Operator.eq,type = InputType.dictionary,classType = Integer.class)
    @FormField(title = "是否有车", grid = true,type = InputType.dictionary)
    private Integer hasCar;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "有"),
                    @DictItem(value = 0, label = "无")
            }
    )
    @Comment("是否有房")
    @SearchItem(name = "hasHouse", key = "hasHouse", label = "是否有房",operator = Operator.eq,type = InputType.dictionary,classType = Integer.class)
    @FormField(title = "是否有房",  grid = true,type = InputType.dictionary)
    private Integer hasHouse;

    @Comment("择偶要求")
    @FormField(title = "择偶要求", grid = true, type = InputType.richText)
    private String partnerRequirements;


    @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    private UserInfo creator;

    @SearchItem(name = "storeState",label = "状态",operator = Operator.eq,classType = StoreState.class)
    private StoreState storeState;

}
